﻿using ConfExpert.Utility;
using DevExpress.XtraEditors;
using DevTeam;
using System;
using System.Windows.Forms;

namespace ConfExpert.Forms.Depo
{
    public partial class CopyScanFrom : XPopupForm
    {
        int productId1;
        public CopyScanFrom(int ProductId)
        {
            InitializeComponent();
            this.productId1 = ProductId;
        }

        private void CopyScanFrom_Load(object sender, EventArgs e)
        {

            gleCopyPhoto.Edit.Assign(RI(Rp.V_Kumas));

            btnCopy.Click += btnCopy_Click;
        }

        void btnCopy_Click(object sender, EventArgs e)
        {
            if (intParse(gleCopyPhoto.EditValue) > 0)
            {
                int productId2 = gleCopyPhoto.EditValue.ToInt();

                string article1 = AppSession.Lookups.V_Kumas.FindByProductId(productId1).Name;
                string article2 = AppSession.Lookups.V_Kumas.FindByProductId(productId2).Name;

                if (XtraMessageBox.Show(article2 + " kumaşının resimlerini " + article1 + " kumaşı için yüklemek üzeresiniz. Devam etmek istiyor musunuz ?", "Critical", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                {
                    gleCopyPhoto.EditValue = 0;
                    return;
                }

                GetDetails("Product", "UpdPhotoFromAnotherProduct", productId1, productId2);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }
    }
}
